export const debounce = function (func, delay = 300) {
    let context = this as any;//在ts中需要这样写
    let args = arguments;
    return function () {
      if (context.timeout) {
        clearTimeout(context.timeout);
      }
      context.timeout = setTimeout(() => {
        func.apply(context, args);
      }, delay);
    };
  };
  export const throttle = function(func,delay = 300){
    let context = this as any;
    let args = arguments;
    return function(){
      if (context.timeout) {
        return
      }
      context.timeout = setTimeout(() => {
        func.apply(context, args);
        context.timeout = null;
      },delay)
    }
  }
  